package hyrpt

class OrderStatusController {
    def dynamicQueryService
    def orderStatus() {
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def pageSizeList = [10, 20, 50, 100]

        def orderStatus=[]
        def totalCount =0
        def tableHeadList = []
        def orderStatusAnalysisStartedList=[]
        def orderStatusSumQty=[]
        if(params.EXPORT_CONTENT_NAME=='Excel'){
            params.SYS_QUERY_NAME = 'orderStatus'
            orderStatus = dynamicQueryService.queryForList(params)
            tableHeadList = []
            if (orderStatus.size() > 0) {
                tableHeadList = orderStatus[0].keySet()
            }
            params.SYS_QUERY_NAME = 'orderStatusCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
            params.SYS_QUERY_NAME = 'orderStatusSumQty'
            orderStatusSumQty = dynamicQueryService.queryForList(params)
        }

        [pageSize     : pageSize,
         totalCount: totalCount,
         pageSizeList: pageSizeList,
         pageCurrent:pageCurrent,
         orderStatus : orderStatus,
         totalCount: totalCount,
         tableHeadList: tableHeadList,
         startno: params.startno ?: '',
         endno: params.endno ?: '',
         docId: params.docId ?: '',
         partName: params.partName ?: '',
         partDesc: params.partDesc ?: '',
         customerOrder: params.customerOrder ?: '',
         orderStatusAnalysisStartedList:orderStatusAnalysisStartedList,
         startedState:params.startedState?:'',
         startTime:params.startTime?:'',
         endTime:params.endTime?:'',
         start:params.start?:'',end:params.end?:'',
         orderStatusSumQty:orderStatusSumQty
        ]
    }
}

